package com.atguigu.gulimall.search.controller;

import com.atguigu.gulimall.search.vo.SearchParam;
import com.atguigu.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.atguigu.gulimall.search.service.MallSearchService ;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletRequest;

/**
 * author: YangDongDong  <br>
 * date: 2025/3/23 下午12:43  <br>
 *
 * @version 1.0  <br>
 * description:
 */
@Controller
public class SearchController
{

    @Autowired
    private MallSearchService mallSearchService;


    @GetMapping("/list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request)
    {
        searchParam.set_queryString(request.getQueryString());
        SearchResult result = mallSearchService.search(searchParam);


        model.addAttribute("result", result);

        return "list";
    }

}
